package example07plus.enity;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class TicketPoint {
    private String pointName;
    List<Ticket> ticketList = new ArrayList<>();
    Random random = new Random();

    public TicketPoint(String pointName) {
        this.pointName = pointName;
    }

    public String getPointName() {
        return pointName;
    }

    public void setPointName(String pointName) {
        this.pointName = pointName;
    }
    public List<Ticket> getTicketList() {
        return ticketList;
    }

    public Ticket getTicket() {
        Ticket t = Railways.sellTicket();
        try {
            Thread.sleep(random.nextInt(50));
        } catch (InterruptedException e) {
            System.out.println(e.getMessage());
        }
        if (t != null) {
            ticketList.add(t);
        }
        return t;
    }
}